package com.example.myDesignPatterns.结构型模式.装饰者模式Decorator;

import lombok.Data;

//配料类
@Data
public abstract class Garnish extends FastFood {
    private FastFood baseItem;//10 炒饭

    //super(fastFood, 1, "鸡蛋");
    public Garnish(FastFood baseItem, float price, String desc) {
        super(price, desc);
        this.baseItem = baseItem;//10 炒饭
    }
//权限修饰符4种  返回类型8种  方法名称
    public String getDesc() {
        return super.getDesc()+baseItem.getDesc();
    }

    @Override
    public float calculateCost() {
        float price = super.getPrice();//1
        float price1 = getBaseItem().getPrice();//10
        return price + price1;
    }


    public float getPrice() {
        float price = super.getPrice();
        float price1 = getBaseItem().getPrice();
        return price + price1;
    }

}

//鸡蛋配料
class Egg extends Garnish {
    public Egg(FastFood fastFood) {
        super(fastFood, 1, "鸡蛋");
    }
}

//培根配料
class Bacon extends Garnish {
    public Bacon(FastFood fastFood) {
        super(fastFood, 2, "培根");
    }
}
